﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using T_Rbac_APi.Application.Command.Operator;

namespace T_Rbac_APi.Controllers
{
    /// <summary>
    /// 操作员
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OperatorController : ControllerBase
    {
        private readonly IMediator mediator;

        /// <summary>
        /// 构造函数注入
        /// </summary>
        /// <param name="mediator"></param>
        public OperatorController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 操作员添加方法
        /// </summary>
        /// <param name="operatorAddCommand"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int>AddOperator(OperatorAddCommand operatorAddCommand)
        {
            return await mediator.Send(operatorAddCommand);
        }
        /// <summary>
        /// 更新操作员方法
        /// </summary>
        /// <param name="operatorUpdateCommand"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int>UpdateOperator(OperatorUpdateCommand operatorUpdateCommand)
        {
            return await mediator.Send(operatorUpdateCommand);
        }
        /// <summary>
        /// 删除操作员方法
        /// </summary>
        /// <param name="operatorDeleteCommand"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> DeleteOpertor([FromQuery] OperatorDeleteCommand operatorDeleteCommand)
        {
           return await mediator.Send(operatorDeleteCommand);
        }
        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="operatorUpdateStateByidCommand"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int>UpdateOperatorStateByid(OperatorUpdateStateByidCommand operatorUpdateStateByidCommand)
        {
            return await mediator.Send(operatorUpdateStateByidCommand);
        }
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="operatorDeleteListCommand"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> DeleteOperatorListByids([FromQuery]OperatorDeleteListCommand operatorDeleteListCommand)
        {
            return await mediator.Send(operatorDeleteListCommand);
        }
    }
}
